<template>
  <div class="hotgood clearfix">
    <h3 style="text-align=center">限时特惠</h3>
    <div class="hotgoodinit">
      <div v-for="item in SecKillGoodList" :key="item.goodId">
        <el-card :body-style="{ padding: '0px'   }" class="card">
          <img :src="item.goodImgUrl" alt="图片丢失了" class="goodImg" />
          <div style="padding: 14px;">
            <span>{{item.goodName}}</span>
            <div class="bottom clearfix">
              <div>销量:{{item.goodSell}}</div>
              <el-button type="text" class="button" @click="gotoGoodDetail(item.goodId)">立刻抢购</el-button>
            </div>
          </div>
        </el-card>
      </div>
    </div>
  </div>
</template>

<script>
import { getSecKillGoodInfo } from "../api/requestapi";
export default {
  name: "SecKillGood",

  data() {
    return {
      SecKillGoodList: [],
    };
  },

  methods: {
    //跳转商品页面
    gotoGoodDetail(goodId) {
      alert(goodId);
      this.$router.push({ path: "/GoodDetail", query: { goodId: goodId } });
    },
  },

  created() {
    getSecKillGoodInfo().then((response) => {
      this.SecKillGoodList = response.data;
    });
  },
};
</script>

<style>
.card {
  width: 380px;
  height: 300px;
  float: left;
  margin-left: 20px;
  margin-bottom: 20px;
}

.hotgood {
  width: 1700px;
  margin-bottom: 20px;
  margin: 0 auto;
}

.goodImg {
  height: 150px;
  width: 380px;
}

.hotgoodinit {
  width: 1700px;
  margin-left: auto;
  margin-right: auto;
}

/* 清除浮动 */
.clearfix:after {
  content: "020";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.clearfix {
  /* 触发 hasLayout */
  zoom: 1;
}
</style>